package jk.fox.exchange.server;

import jk.fox.common.payload.request.Request;
import jk.fox.common.payload.response.RpcResponse;
import jk.fox.common.payload.server.Server;
import jk.fox.engine.listener.RpcServiceStartedListener;

/**
 * @author cuichao
 * @Description: ServerExchange
 * @Date: create in 2020/4/14 14:27
 */
public interface ServerExchange {
   /**
    * 绑定并启动服务
    * @param port
    */
   void bind(int port);
   /**
    * 接受远程请求
    * @param request
    * @return
    */
   RpcResponse received(Request request);
   /**
    * 得到服务方对象
    * @return
    */
   Server server();
   /**
    * 设置服务方地址和状态并发布事件
    * @param server
    */
   void publishServer(Server server);
   /**
    * 添加启动监听器
    * @param listener
    */
   void addListener(RpcServiceStartedListener listener);
}
